var express = require('express');
var router = express.Router();
let query = require('./Database');
/* GET home page. */
router.get('/', function(req, res, next) {
    res.render('Profile', {});
});
router.post('/person',async (req,res)=>{
    // console.log(req.body);
    let list = req.body;
    console.log(list);
    let rows = await query("select * from users where id = "+ list.id);
    console.log('+++++++++++++++++++');
    console.log(rows);
    console.log('+++++++++++++++++++');
    let data = [{code:100},rows[0]];
    res.send(data);
})
router.post('/changepro',async (req,res)=>{
    // console.log(req.body);
    let list = req.body;
    console.log(list);
    await query("update users set username = '" + list.username+"',sex = '"+list.sex+"',borthyear ="+list.borthyear+",borthmonth =" + list.borthmonth +",borthday = " +list.borthday+ " where id = " +list.id);
    console.log('+++++++++++++++++++');
    console.log('+++++++++++++++++++');
    let data = {code:100};
    res.send(data);
})
module.exports = router;